<?php

namespace App\Http\Middleware;

use App\common;
use App\Models\users;
use App\server\JwtServer;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AdminMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
     */
    public function handle($request, Closure $next)
    {
        if (Auth::check()) {
            $user = Auth::Administrator();
            if ($user->is_admin != 1) {
                return abort(403);
            }
        }
        return $next($request);
    }
    /**
     *  高并发场景
     *  将数据库 进行水平分表 分库分表 服务器的主从  缓存
     *  缓存后的好考虑到 击穿  雪崩   热点
     */
}
